package com.tbit.uqbike.object.pojo;

import com.alibaba.fastjson.annotation.JSONField;
import com.tbit.uqbike.annos.Excel;
import com.tbit.uqbike.webmanager.util.csv.annotations.Csv;
import com.tbit.uqbike.webmanager.util.csv.annotations.Sum;
import lombok.Data;

import java.util.Date;

/**
 * @Author:BUGTian
 * @DATE: 2022/6/2
 */
@Data
public class RideFeeLog {


    /**
     * 订单编号
     */
    @Csv(name = "订单编号")
    @Excel(name = "订单编号", sort = 2)
    private String orderNO;

    /**
     * 用户id
     */
    private Integer userId;

    /**
     * 区域Id
     */
    private Integer accountId;

    /**
     * 品牌id
     */
    private Integer brandId;

    /**
     * 总费用
     */
    private Integer money;

    /**
     * 分账金额
     */
    private Integer realMoney;

    /**
     * 不支持分账金额
     */
    private Integer overMoney;

    /**
     * 状态
     */
    private Integer state;

    /**
     * 添加时间
     */
    @Csv(name = "时间")
    @Excel(name = "时间", dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 1)
    private Date addTime;

    /**
     * 备注
     */
    private String remark;

    /**
     * 总退款金额
     */
    private Integer refundMoney;

    /**
     * 分账退款金额
     */
    private Integer refundRealMoney;

    /**
     * 其他退款金额
     */
    private Integer refundOverMoney;

    /**
     * 订单类型
     */

    @Excel(name = "订单类型", readConverterExp = "0=充值,1=免押卡,2=骑行卡,3=骑行订单,4=vip会员卡,5=优惠券套餐", sort = 3)
    @Csv(name = "订单类型", keys = {"0", "1", "2", "3", "4", "5"}, values = {"充值", "免押卡", "骑行卡", "骑行订单", "vip会员卡", "优惠券套餐"})
    private Integer type;

    /**
     * 区域名称
     */
    @Excel(name = "区域", sort = 4)
    @Csv(name = "区域")
    private String areaName;

    @JSONField(serialize = false)
    @Excel(name = "总费用", sort = 5)
    @Csv(name = "总费用")
    @Sum
    private String moneyYuan;

    @JSONField(serialize = false)
    @Excel(name = "分账金额", sort = 6)
    @Csv(name = "分账金额")
    @Sum
    private String realMoneyYuan;

    @JSONField(serialize = false)
    @Excel(name = "不支持分账金额", sort = 7)
    @Csv(name = "不支持分账金额")
    @Sum
    private String overMoneyYuan;

    @JSONField(serialize = false)
    @Excel(name = "总退款金额", sort = 8)
    @Csv(name = "总退款金额")
    @Sum
    private String refundMoneyYuan;

    @JSONField(serialize = false)
    @Excel(name = "分账退款金额", sort = 9)
    @Csv(name = "分账退款金额")
    @Sum
    private String refundRealMoneyYuan;

    @JSONField(serialize = false)
    @Excel(name = "其他退款金额", sort = 9)
    @Csv(name = "其他退款金额")
    @Sum
    private String refundOverMoneyYuan;

    /**
     * 单位转换
     */
    public void unitConversion() {
        this.moneyYuan = String.format("%.2f", ((double) money / 100D));
        this.realMoneyYuan = String.format("%.2f", ((double) realMoney / 100D));
        this.overMoneyYuan = String.format("%.2f", ((double) overMoney / 100D));
        this.refundMoneyYuan = String.format("%.2f", ((double) refundMoney / 100D));
        this.refundRealMoneyYuan = String.format("%.2f", ((double) refundRealMoney / 100D));
        this.refundOverMoneyYuan = String.format("%.2f", ((double) refundOverMoney / 100D));
    }

    public String getMoneyYuan() {
        return String.format("%.2f", ((double) money / 100D));
    }

    public String getRealMoneyYuan() {
        return String.format("%.2f", ((double) realMoney / 100D));
    }

    public String getOverMoneyYuan() {
        return String.format("%.2f", ((double) overMoney / 100D));
    }

    public String getRefundMoneyYuan() {
        return String.format("%.2f", ((double) refundMoney / 100D));
    }

    public String getRefundRealMoneyYuan() {
        return String.format("%.2f", ((double) refundRealMoney / 100D));
    }

    public String getRefundOverMoneyYuan() {
        return String.format("%.2f", ((double) refundOverMoney / 100D));
    }
}
